package com.woniuxy.microstockserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.microstockserver.bean.AllocationBean;
import com.woniuxy.microstockserver.bean.PageRequestBean;
import com.woniuxy.microstockserver.mapper.AllocationMapper;
import com.woniuxy.microstockserver.service.IAllocationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 赵雄伟
 * 调拨单impl
 */
@Service
public class AllocationServiceImpl implements IAllocationService {
    @Resource
    private AllocationMapper allocationMapper;

    @Override
    public PageInfo<AllocationBean> findAllAllcationBean(PageRequestBean pageRequestBean, AllocationBean allocationBean) {
        return PageHelper.startPage(pageRequestBean.getPageNum(),pageRequestBean.getLimit()).
                doSelectPageInfo(()->allocationMapper.findAllAllcationBean(pageRequestBean, allocationBean));
    }

    @Override
    public Long saveAllocationBean(AllocationBean allocationBean) {
        allocationMapper.saveAllocationBean(allocationBean);
        Long alloId = allocationBean.getId();
        return alloId;
    }

    @Override
    public AllocationBean findAllocationAndGoodsDetail(Long id) {
        return allocationMapper.findAllocationAndGoodsDetail(id);
    }

    @Override
    public Long upadteAllocationBean(AllocationBean allocationBean) {
        allocationMapper.upadteAllocationBean(allocationBean);
        return allocationBean.getId();
    }
}
